<?php
class ArticlesController extends AppController{

	public $helpers = array('Form', 'Html');

	public function index($short = null){
		if(!empty($this->request->data)){
			$this->Article->save($this->request->data);
		}
		if(!empty($short)){
			$conditions = array('fields'=> 'id', 'title');
			$result = $this->Article->find('all', $conditions);
		}else{
//			$result = $this->Article->findAll();
			$result = $this->Article->find('all');


		}

		if(isset($this->params['requested'])){
			return $result;
		}
		$this->set('title', 'Articles');
		$this->set('articles', $result);

	}

	/* 
	 * In this case //more code will not be executed as the method will return 
	 * once the redirect is reached
	 */
	public function add(){
		if($this->request->is('post')){
			if($this->Article->save($this->request->data)){
				return $this->redirect(array('action' => 'index'));
			}
		}
		//more code
	}


}

?>
